package com.imooc.activiti.example;

import org.activiti.engine.delegate.BpmnError;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.Expression;
import org.activiti.engine.delegate.JavaDelegate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;
import java.util.Objects;

/**
 * test
 * @author zyg
 */
public class MyPayJavaDelegate implements JavaDelegate,Serializable {
    public static final Logger LOGGER=LoggerFactory.getLogger(MyPayJavaDelegate.class);

    @Override
    public void execute(DelegateExecution delegateExecution) {

        LOGGER.info("variables={}",delegateExecution.getVariables());
        LOGGER.info("run my java delegate {}",this );
        delegateExecution.getParent().setVariableLocal("key2","value2");
        delegateExecution.setVariable("key1","value1");
        delegateExecution.setVariable("key3","value3");
        Object errorflag = delegateExecution.getVariable("errorflag");
        if (Objects.equals(errorflag,true)){
            throw new BpmnError("bpmnError");
        }

    }

}
